package grape.sequence.service.config.api;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import grape.sequence.service.config.po.Config;
import grape.common.service.common.IBaseService;

/**
 * <p>
 * 序列生成配置表 服务类
 * </p>
 *
 * @author yangwei
 * @since 2020-08-20
 */
public interface IConfigService extends IBaseService<Config> {

    /**
     * 根据编码查询
     * @param code
     * @return
     */
    default Config getByCode(String code){
        assertParamNotEmpty(code,"code 不能为空");
        Config query = new Config();
        query.setCode(code);
        return getOne(query);
    }

    /**
     * 判断编码是否已存在
     * @param code
     * @return
     */
    default boolean existCode(String code){
        assertParamNotEmpty(code,"code 不能为空");

        Config query = new Config();
        query.setCode(code);
        int r = count(Wrappers.query(query));
        return r > 0;
    }
}
